home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / dev / gcc / gcc270_src.lha / gcc-2.7.0-amiga / make-cc1.com < prev    next >
Text File  |  1995-05-19  |  15KB  |  495 lines

  1. $! Set the def dir to proper place for use in batch. Works for interactive too.
  2. $flnm = f$enviroment("PROCEDURE")     ! get current procedure name
  3. $set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")'
  4. $!
  5. $ v=f$verify(0)
  6. $!
  7. $! CAUTION: If you want to link gcc-cc1 to the sharable image library
  8. $! VAXCRTL, see the notes in gcc.texinfo (or INSTALL) first.
  9. $!
  10. $!    Build the GNU "C" compiler on VMS
  11. $!
  12. $!  Note:  to build with DEC's VAX C compiler, uncomment the 2nd CC, CFLAGS,
  13. $!       and LIBS alternatives, and also execute the following command:
  14. $!    DEFINE SYS SYS$LIBRARY:
  15. $!       After a successful build, restore those items and rebuild with gcc.
  16. $
  17. $!    C compiler
  18. $!
  19. $ CC    =    "gcc"
  20. $! CC    =    "cc"    !uncomment for VAXC
  21. $ BISON    =    "bison"
  22. $ BISON_FLAGS=    "/Define/Verbose"
  23. $ RENAME=    "rename/New_Version"
  24. $ LINK    =    "link"
  25. $ EDIT    =    "edit"
  26. $ SEARCH=    "search"
  27. $ ABORT    =    "exit %x002C"
  28. $ echo    =    "write sys$output"
  29. $!
  30. $!    Compiler options
  31. $!
  32. $ CFLAGS =    "/Debug/noVerbos/CC1=""-mpcc-alignment"""
  33. $! CFLAGS =    "/noOpt"        !uncomment for VAXC
  34. $ CINCL1 =    "/Incl=[]"            !stage 1 -I flags
  35. $ CINCL2 =    "/Incl=([],[.ginclude])"    !stage 2,3,... flags
  36. $ CINCL_SUB =    "/Incl=([],[-],[-.ginclude])"    ![.cp] flags
  37. $!
  38. $!    Link options
  39. $!
  40. $ LDFLAGS =    "/noMap"
  41. $!
  42. $!    Link libraries
  43. $!
  44. $ LIBS = "gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr"
  45. $! LIBS = "alloca.obj,sys$library:vaxcrtl.olb/Libr"    !uncomment for VAXC
  46. $
  47. $!!!!!!!
  48. $!    Nothing beyond this point should need any local configuration changes.
  49. $!!!!!!!
  50. $
  51. $!
  52. $!  First we figure out what needs to be done.  This is sort of like a limited
  53. $! make facility - the command line options specify exactly what components
  54. $! we want to build.  The following options are understood:
  55. $!
  56. $!    LINK:    Assume that the object modules for the selected compiler(s)
  57. $!        have already been compiled, perform link phase only.
  58. $!
  59. $!    CC1:    Compile and link "C" compiler.
  60. $!
  61. $!    CC1PLUS:Compile and link "C++" compiler.
  62. $!
  63. $!    CC1OBJ:    Compile and link objective C compiler.
  64. $!
  65. $!    ALL:    Compile and link all of the CC1 passes.
  66. $!
  67. $!    INDEPENDENT:
  68. $!        Compile language independent source modules. (On by default).
  69. $!
  70. $!    BC:
  71. $!        Compile byte compiler source modules. (On by default).
  72. $!
  73. $!    DEBUG:    Link images with /debug.
  74. $!
  75. $! If you want to list more than one option, you should use a spaces to
  76. $! separate them.
  77. $!
  78. $!    Any one of the above options can be prefaced with a "NO".  For example,
  79. $! if you had already built GCC, and you wanted to build G++, you could use the
  80. $! "CC1PLUS NOINDEPENDENT" options, which would only compile the C++ language
  81. $! specific source files, and then link the C++ compiler.
  82. $!
  83. $! If you do not specify which compiler you want to build, it is assumed that
  84. $! you want to build GNU-C ("CC1").
  85. $!
  86. $! Now figure out what we have been requested to do.
  87. $p1 = p1+" "+p2+" "+p3+" "+p4+" "+p5+" "+p6+" "+p7 
  88. $p1 = f$edit(p1,"COMPRESS,TRIM")
  89. $i=0
  90. $DO_ALL = 0
  91. $DO_LINK = 0
  92. $DO_DEBUG = 0
  93. $DO_CC1PLUS = 0
  94. $DO_CC1OBJ = 0
  95. $DO_OBJCLIB = 0
  96. $if f$trnlnm("cfile$").nes."" then  close/noLog cfile$
  97. $open cfile$ compilers.list
  98. $cinit:read cfile$ compilername/end=cinit_done
  99. $DO_'compilername'=0
  100. $goto cinit
  101. $cinit_done: close cfile$
  102. $DO_INDEPENDENT = 1
  103. $DO_DEFAULT = 1
  104. $DO_BC = 1
  105. $loop:
  106. $string = f$element(i," ",p1)
  107. $if string.eqs." " then goto done
  108. $flag = 1
  109. $if string.eqs."CC1PLUS" then DO_DEFAULT = 0
  110. $if string.eqs."CC1OBJ" then DO_DEFAULT = 0
  111. $if string.eqs."OBJCLIB"
  112. $then    DO_DEFAULT = 0
  113. $    DO_INDEPENDENT = DO_CC1OBJ
  114. $    DO_BC = DO_CC1OBJ
  115. $endif
  116. $if f$extract(0,2,string).nes."NO" then goto parse_option
  117. $  string=f$extract(2,f$length(string)-2,string)
  118. $  flag = 0
  119. $parse_option:
  120. $DO_'string' = flag
  121. $i=i+1
  122. $goto loop
  123. $!
  124. $done:
  125. $if DO_DEFAULT.eq.1 then DO_CC1 = 1
  126. $echo "This command file will now perform the following actions:
  127. $if DO_LINK.eq.1 then goto link_only
  128. $if DO_ALL.eq.1 then echo "   Compile all language specific object modules."
  129. $if DO_CC1.eq.1 then echo "   Compile C specific object modules."
  130. $if DO_CC1PLUS.eq.1 then echo "   Compile C++ specific object modules."
  131. $if DO_CC1OBJ.eq.1 then echo "   Compile obj-C specific object modules."
  132. $if DO_INDEPENDENT.eq.1 then echo "   Compile language independent object modules."
  133. $if DO_BC.eq.1 then echo "   Compile byte compiler object modules."
  134. $if DO_OBJCLIB.eq.1 then echo "   Create Objective-C run-time library."
  135. $link_only:
  136. $if DO_CC1.eq.1 then    echo "   Link C compiler (gcc-cc1.exe)."
  137. $if DO_CC1PLUS.eq.1 then echo "   Link C++ compiler (gcc-cc1plus.exe)."
  138. $if DO_CC1OBJ.eq.1 then echo "   Link objective-C compiler (gcc-cc1obj.exe)."
  139. $if DO_DEBUG.eq.1 then echo  "   Link images to run under debugger."
  140. $!
  141. $! Update CFLAGS with appropriate CINCLx value.
  142. $!
  143. $if f$edit(f$extract(0,3,CC),"LOWERCASE").nes."gcc" then goto stage1
  144. $if f$search("gcc-cc1.exe").eqs."" then goto stage1
  145. $if f$file_attr("gnu_cc:[000000]gcc-cc1.exe","FID").nes.-
  146.     f$file_attr("gcc-cc1.exe","FID") then goto stage1
  147. $ CFLAGS = CFLAGS + CINCL2
  148. $ goto cinclX
  149. $stage1:
  150. $ CFLAGS = CFLAGS + CINCL1
  151. $cinclX:
  152. $!
  153. $! Test and see if we need these messages or not.  The -1 switch gives it away.
  154. $!
  155. $gas := $gnu_cc:[000000]gcc-as.exe
  156. $if f$search(gas-"$").eqs."" then  goto gas_message    !must be VAXC
  157. $define/user sys$error sys$scratch:gas_test.tmp
  158. $gas -1 nla0: -o nla0:
  159. $size=f$file_attributes("sys$scratch:gas_test.tmp","ALQ")
  160. $delete/nolog sys$scratch:gas_test.tmp;*
  161. $if size.eq.0 then goto no_message
  162. $gas_message:
  163. $type sys$input
  164.  
  165.     Note: GCC 2.x treats external variables differently than GCC 1.x does.
  166. Before you use GCC 2.x, you should obtain a version of the assembler which
  167. contains the patches to work with GCC 2.x (GCC-AS 1.38 does not contain
  168. these patches - whatever comes after this probably will).  The assembler
  169. in gcc-vms-1.42.tar.gz from prep does contain the proper patches.
  170.  
  171.     If you do not update the assembler, the compiler will still work,
  172. but `extern const' variables will be treated as `extern'.  This will result
  173. in linker warning messages about mismatched psect attributes, and these
  174. variables will be placed in read/write storage.
  175.  
  176. $!
  177. $no_message:
  178. $!
  179. $!
  180. $ if DO_DEBUG.eq.1 then LDFLAGS = LDFLAGS + "/Debug"
  181. $!
  182. $if DO_LINK.eq.1 then goto compile_cc1
  183. $!
  184. $! Build alloca if necessary (in 'LIBS for use with VAXC)
  185. $!
  186. $ if f$locate("alloca.obj",f$edit(LIBS,"lowercase")).ge.f$length(LIBS) then -
  187.     goto skip_alloca
  188. $ if f$search("alloca.obj").nes."" then -  !does .obj exist? is it up to date?
  189.     if f$cvtime(f$file_attributes("alloca.obj","RDT")).gts.-
  190.        f$cvtime(f$file_attributes("alloca.c","RDT")) then  goto skip_alloca
  191. $set verify
  192. $ 'CC''CFLAGS'/Define="STACK_DIRECTION=(-1)" alloca.c
  193. $!'f$verify(0)
  194. $skip_alloca:
  195. $!
  196. $if DO_BC.eq.1 
  197. $    THEN 
  198. $    call compile bi_all.opt ""
  199. $    if f$trnlnm("ifile$").nes."" then  close/noLog ifile$
  200. $    open ifile$ bc_all.list
  201. $    read ifile$ bc_line
  202. $    close ifile$
  203. $    bc_index = 0
  204. $bc_loop:
  205. $    tfile = f$element(bc_index, ",", bc_line)
  206. $    if tfile.eqs."," then goto bc_done
  207. $    call bc_generate 'tfile' "bi_all.opt/opt,"
  208. $    bc_index = bc_index + 1
  209. $    goto bc_loop
  210. $bc_done:
  211. $    endif
  212. $!
  213. $!
  214. $if DO_INDEPENDENT.eq.1 
  215. $    THEN 
  216. $!
  217. $! First build a couple of header files from the machine description
  218. $! These are used by many of the source modules, so we build them now.
  219. $!
  220. $set verify
  221. $ 'CC''CFLAGS' rtl.c
  222. $ 'CC''CFLAGS' obstack.c
  223. $!'f$verify(0)
  224. $! Generate insn-attr.h
  225. $    call generate insn-attr.h
  226. $    call generate insn-flags.h
  227. $    call generate insn-codes.h
  228. $    call generate insn-config.h
  229. $!
  230. $call compile independent.opt "rtl,obstack,insn-attrtab"
  231. $!
  232. $    call generate insn-attrtab.c "rtlanal.obj,"
  233. $set verify
  234. $ 'CC''CFLAGS' insn-attrtab.c
  235. $ 'CC''CFLAGS' bc-emit.c
  236. $ 'CC''CFLAGS' bc-optab.c
  237. $!'f$verify(0)
  238. $    endif
  239. $!
  240. $compile_cc1:
  241. $if (DO_CC1 + DO_CC1OBJ) .ne.0
  242. $    then
  243. $if (f$search("C-PARSE.Y") .eqs. "") then goto yes_yfiles
  244. $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
  245.          f$cvtime(f$file_attributes("C-PARSE.Y","RDT")))  -
  246.         then goto yes_yfiles
  247. $if (f$search("OBJC-PARSE.Y") .eqs. "") then goto yes_yfiles
  248. $if (f$cvtime(f$file_attributes("C-PARSE.IN","RDT")).gts. -
  249.          f$cvtime(f$file_attributes("OBJC-PARSE.Y","RDT")))  -
  250.         then goto yes_yfiles
  251. $GOTO no_yfiles
  252. $yes_yfiles:
  253. $echo "Now processing c-parse.in to generate c-parse.y and objc-parse.y."
  254. $ edit/tpu/nojournal/nosection/nodisplay/command=sys$input
  255. !
  256. !     Read c-parse.in, write c-parse.y and objc-parse.y, depending on
  257. !     paired lines of "ifc" & "end ifc" and "ifobjc" & "end ifobjc" to
  258. !     control what goes into each file.  Most lines will be common to
  259. !     both (hence not bracketed by either control pair).  Mismatched
  260. !     pairs aren't detected--garbage in, garbage out...
  261. !
  262.  
  263.    PROCEDURE do_output()
  264.       IF NOT objc_only THEN POSITION(END_OF(c)); COPY_TEXT(input_line); ENDIF;
  265.       IF NOT c_only THEN POSITION(END_OF(objc)); COPY_TEXT(input_line); ENDIF;
  266.       POSITION(input_file);                     !reset
  267.    ENDPROCEDURE;
  268.  
  269.    input_file := CREATE_BUFFER("input", "c-parse.in");  !load data
  270.          SET(NO_WRITE, input_file);
  271.    c          := CREATE_BUFFER("c_output");     !1st output file
  272.    objc       := CREATE_BUFFER("objc_output");  !2nd output file
  273.  
  274.    POSITION(BEGINNING_OF(input_file));
  275.    c_only     := 0;
  276.    objc_only  := 0;
  277.  
  278.    LOOP
  279.       EXITIF MARK(NONE) = END_OF(input_file);   !are we done yet?
  280.  
  281.       input_line := CURRENT_LINE;               !access current_line just once
  282.       CASE EDIT(input_line, TRIM_TRAILING, OFF, NOT_IN_PLACE)
  283.      ["ifc"]        : c_only := 1;
  284.      ["end ifc"]    : c_only := 0;
  285.      ["ifobjc"]     : objc_only := 1;
  286.      ["end ifobjc"] : objc_only := 0;
  287. !         default -- add non-control line to either or both output files
  288.      [INRANGE]      : do_output();          !between "end" and "if"
  289.      [OUTRANGE]     : do_output();          !before "end" or after "if"
  290.       ENDCASE;
  291.  
  292.       MOVE_VERTICAL(1);                         !go to next line
  293.    ENDLOOP;
  294.  
  295.    WRITE_FILE(c, "c-parse.y");
  296.    WRITE_FILE(objc, "objc-parse.y");
  297.    QUIT
  298. $    endif    
  299. $no_yfiles:
  300. $!
  301. $open cfile$ compilers.list
  302. $cloop:read cfile$ compilername/end=cdone
  303. $! language specific modules
  304. $!
  305. $if (DO_ALL + DO_'compilername').eq.0 then goto cloop
  306. $if DO_LINK.eq.0 then -
  307.  call compile 'compilername'-objs.opt "obstack,bc-emit,bc-optab"
  308. $!
  309. $! CAUTION: If you want to link gcc-cc1* to the sharable image library
  310. $! VAXCRTL, see the notes in gcc.texinfo (or INSTALL) first.
  311. $!
  312. $set verify
  313. $ 'LINK''LDFLAGS'/Exe=gcc-'compilername'.exe  version.opt/Opt,-
  314.       'compilername'-objs.opt/Opt,independent.opt/Opt,-
  315.       'LIBS'
  316. $!'f$verify(0)
  317. $goto cloop
  318. $!
  319. $!
  320. $cdone: close cfile$
  321. $!
  322. $ if DO_OBJCLIB
  323. $ then    set default [.objc]    !push
  324. $    save_cflags = CFLAGS
  325. $    CFLAGS = CFLAGS - CINCL1 - CINCL2 + CINCL_SUB
  326. $    MFLAGS = "/Lang=ObjC" + CFLAGS
  327. $    library/Obj [-]objclib.olb/Create
  328. $    if f$trnlnm("IFILE$").nes."" then  close/noLog ifile$
  329. $    open/Read ifile$ [-]objc-objs.opt
  330. $ocl1:    read/End=ocl3 ifile$ line
  331. $    i = 0
  332. $ocl2:    o = f$element(i,",",line)
  333. $    if o.eqs."," then goto ocl1
  334. $    n = o - ".o"
  335. $    if f$search(n + ".m").nes.""
  336. $    then    f = n + ".m"
  337. $        flags = MFLAGS
  338. $    else    f = n + ".c"
  339. $        flags = CFLAGS
  340. $    endif
  341. $    set verify
  342. $ 'CC' 'flags' 'f'
  343. $!'f$verify(0)'
  344. $    library/Obj [-]objclib.olb 'n'.obj/Insert
  345. $    delete/noConfirm/noLog 'n'.obj;*
  346. $    i = i + 1
  347. $    goto ocl2
  348. $ocl3:    close ifile$
  349. $    CFLAGS = save_cflags
  350. $    set default [-]    !pop
  351. $ endif !DO_OBJCLIB
  352. $!
  353. $!    Done
  354. $!
  355. $! 'f$verify(v)
  356. $exit
  357. $!
  358. $!  Various DCL subroutines follow...
  359. $!
  360. $!  This routine takes parameter p1 to be a linker options file with a list
  361. $!  of object files that are needed.  It extracts the names, and compiles
  362. $!  each source module, one by one.  File names that begin with an
  363. $!  "INSN-" are assumed to be generated by a GEN*.C program.
  364. $!
  365. $!  Parameter P2 is a list of files which will appear in the options file
  366. $!  that should not be compiled.  This allows us to handle special cases.
  367. $!
  368. $compile:
  369. $subroutine
  370. $on error then goto c_err
  371. $on control_y then goto c_err
  372. $open ifile$ 'p1'
  373. $loop: read ifile$ line/end=c_done
  374. $!
  375. $i=0
  376. $loop1:
  377. $flnm=f$element(i,",",line)
  378. $i=i+1
  379. $if flnm.eqs."" then goto loop
  380. $if flnm.eqs."," then goto loop
  381. $if f$locate(flnm,p2).lt.f$length(p2) then goto loop1
  382. $! check for front-end subdirectory: "[.prfx]flnm"
  383. $prfx = ""
  384. $k = f$locate("]",flnm)
  385. $if k.eq.1    ![]c-common for [.cp]
  386. $then
  387. $ if f$search(f$parse(".obj",flnm)).nes."" then  goto loop1
  388. $ flnm = f$extract(2,999,flnm)
  389. $else if k.lt.f$length(flnm)
  390. $ then    prfx = f$extract(2,k-2,flnm)
  391. $    flnm = f$extract(k+1,99,flnm)
  392. $ endif
  393. $endif
  394. $ if prfx.nes.""
  395. $ then    set default [.'prfx']    !push
  396. $    save_cflags = CFLAGS
  397. $    CFLAGS = CFLAGS - CINCL1 - CINCL2 + CINCL_SUB
  398. $ endif
  399. $!
  400. $if f$locate("parse",flnm).nes.f$length(flnm)
  401. $    then
  402. $    if (f$search("''flnm'.C") .eqs. "") then goto yes_bison
  403. $    if (f$cvtime(f$file_attributes("''flnm'.Y","RDT")).les. -
  404.          f$cvtime(f$file_attributes("''flnm'.C","RDT")))  -
  405.         then goto no_bison
  406. $yes_bison:
  407. $set verify
  408. $     'BISON''BISON_FLAGS' 'flnm'.y
  409. $     'RENAME' 'flnm'_tab.c 'flnm'.c
  410. $     'RENAME' 'flnm'_tab.h 'flnm'.h
  411. $!'f$verify(0)
  412. $    if flnm.eqs."cp-parse" .or. (prfx.eqs."cp" .and. flnm.eqs."parse")
  413. $    then        ! fgrep '#define YYEMPTY' cp-parse.c >>cp-parse.h
  414. $        open/Append jfile$ 'flnm'.h
  415. $        'SEARCH'/Exact/Output=jfile$ 'flnm'.c "#define YYEMPTY"
  416. $        close jfile$
  417. $    endif
  418. $no_bison:
  419. $     echo " (Ignore any warning about not finding file ""bison.simple"".)"
  420. $    endif
  421. $!
  422. $if f$extract(0,5,flnm).eqs."insn-" then call generate 'flnm'.c
  423. $!
  424. $set verify
  425. $ 'CC''CFLAGS' 'flnm'.c
  426. $!'f$verify(0)
  427. $ if prfx.nes.""
  428. $ then    set default [-]        !pop
  429. $    CFLAGS = save_CFLAGS
  430. $ endif
  431. $
  432. $goto loop1
  433. $!
  434. $!
  435. $! In case of error or abort, go here (In order to close file).
  436. $!
  437. $c_err: !'f$verify(0)
  438. $close ifile$
  439. $ABORT
  440. $!
  441. $c_done:
  442. $close ifile$
  443. $endsubroutine
  444. $!
  445. $! This subroutine generates the insn-* files.  The first argument is the
  446. $! name of the insn-* file to generate.  The second argument contains a 
  447. $! list of any other object modules which must be linked to the gen*.c
  448. $! program.
  449. $!
  450. $generate:
  451. $subroutine
  452. $if f$extract(0,5,p1).nes."INSN-"
  453. $    then
  454. $    write sys$error "Unknown file passed to generate."
  455. $    ABORT
  456. $    endif
  457. $root1=f$parse(f$extract(5,255,p1),,,"NAME")
  458. $    set verify
  459. $ 'CC''CFLAGS' GEN'root1'.C
  460. $ 'LINK''LDFLAGS' GEN'root1'.OBJ,rtl.obj,obstack.obj,'p2' -
  461.       'LIBS'
  462. $!    'f$verify(0)
  463. $!
  464. $set verify
  465. $    assign/user 'p1' sys$output:
  466. $    mcr sys$disk:[]GEN'root1' vax.md
  467. $!'f$verify(0)
  468. $endsubroutine
  469. $!
  470. $! This subroutine generates the bc-* files.  The first argument is the
  471. $! name of the bc-* file to generate.  The second argument contains a 
  472. $! list of any other object modules which must be linked to the bi*.c
  473. $! program.
  474. $!
  475. $bc_generate:
  476. $subroutine
  477. $if f$extract(0,3,p1).nes."BC-"
  478. $    then
  479. $    write sys$error "Unknown file passed to bc_generate."
  480. $    ABORT
  481. $    endif
  482. $root1=f$parse(f$extract(3,255,p1),,,"NAME")
  483. $    set verify
  484. $ 'CC''CFLAGS' BI-'root1'.C
  485. $ 'LINK''LDFLAGS' BI-'root1'.OBJ,'p2' -
  486.       'LIBS'
  487. $!    'f$verify(0)
  488. $!
  489. $set verify
  490. $    assign/user bytecode.def sys$input:
  491. $    assign/user 'p1' sys$output:
  492. $    mcr sys$disk:[]BI-'root1'
  493. $!'f$verify(0)
  494. $endsubroutine
  495.